home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
- PRODUCT : Delphi NUMBER : 2857
- VERSION : All
- OS : Windows
- DATE : August 22, 1995 PAGE : 1/1
-
- TITLE : How to check to see if a drive is ready.
-
-
-
-
- Q: How can I check to see if there is a disk in the "A" drive
- without an error message box telling you that it is not ready?
-
- A: The following function accepts a drive letter as a parameter,
- and it will return a boolean value that indicates whether
- or not there is a disk in the drive.
-
- function DiskInDrive(Drive: Char): Boolean;
- var
- ErrorMode: word;
- begin
- { make it upper case }
- if Drive in ['a'..'z'] then Dec(Drive, $20);
- { make sure it's a letter }
- if not (Drive in ['A'..'Z']) then
- raise EConvertError.Create('Not a valid drive ID');
- { turn off critical errors }
- ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
- try
- { drive 1 = a, 2 = b, 3 = c, etc. }
- if DiskSize(Ord(Drive) - $40) = -1 then
- Result := False
- else
- Result := True;
- finally
- { restore old error mode }
- SetErrorMode(ErrorMode);
- end;
- end;
-
-
-
-
-
-
-
-
-
-
-
- DISCLAIMER: You have the right to use this technical information
- subject to the terms of the No-Nonsense License Statement that
- you received with the Borland product to which this information
- pertains.
-